﻿using BBICMS.Core;
using BBICMS.Model.Enum;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;


namespace BBICMS.Model.Security
{
    public partial class Menu : AuditableEntity<int>
    {
        public Menu()
        {
            this.EntityName = "菜单";
            this.ChildMenus = new HashSet<Menu>();        
            this.MenuType = MenuType.PAGE;
            this.Roles = new HashSet<Role>();

        }
   

        [Display(Name = "菜单名称", Prompt = "菜单名称")]
        [Required(ErrorMessage = "请输入菜单名称")]
        public string Title { get; set; }

      
        [Display(Name = "链接地址", Prompt = "链接地址")]
        public string Url { get; set; }
        [Display(Name = "域")]
        public string Area { get; set; }
        [Display(Name = "控制器")]
        public string Controller { get; set; }
        [Display(Name = "操作")]
        public string Action { get; set; }

        [Display(Name = "类型", Prompt = "类型")]
        public MenuType MenuType { get; set; }

        [Display(Name = "图标")]
        public string Iconfont { get; set; }

        [Display(Name = "排序", Prompt = "排序")]
        [Required(ErrorMessage = "请输入排序")]
        [RegularExpression(@"^-?\d*$", ErrorMessage = "格式不正确")]
        public int Importance { get; set; }

        [Display(Name = "激活", Prompt = "激活")]
        public bool Active { get; set; }

        //[Display(Name = "隐藏")]
        //public bool Hidden { get; set; }

        [Display(Name = "父级菜单")]
        public int? ParentId { get; set; }
        public virtual Menu ParentMenu { get; set; }
      
        public virtual ICollection<Menu> ChildMenus { get; set; }

        public int CategoryId { get; set; }
        public virtual Category Category { get; set; }

        public virtual ICollection<Role> Roles { get; set; }

        //public IEnumerable<Menu> ParentMenus()
        //{
        //    yield return this;
        //    if (var directSubcategory in Subcategories)
        //        foreach (var subcategory in directSubcategory.AllSubcategories())
        //        {
        //            yield return subcategory;
        //        }
        //}


    }
}
